<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>旅游旅行社后台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">

</head>
<body class="layui-layout-body">

<div id="LAY_app">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <!-- 头部区域 -->
            <ul class="layui-nav layui-layout-left">
                <li class="layui-nav-item layadmin-flexible" lay-unselect>
                    <a href="javascript:;" layadmin-event="flexible" title="侧边伸缩">
                        <i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible"></i>
                    </a>
                </li>

                <li class="layui-nav-item" lay-unselect>
                    <a href="javascript:;" layadmin-event="refresh" title="刷新">
                        <i class="layui-icon layui-icon-refresh-3"></i>
                    </a>
                </li>
            </ul>
            <ul class="layui-nav layui-layout-right" lay-filter="layadmin-layout-right">


                <li class="layui-nav-item layui-hide-xs" lay-unselect>
                    <a href="javascript:;" layadmin-event="theme">
                        <i class="layui-icon layui-icon-theme"></i>
                    </a>
                </li>
                <li class="layui-nav-item layui-hide-xs" lay-unselect>
                    <a href="javascript:;" layadmin-event="note">
                        <i class="layui-icon layui-icon-note"></i>
                    </a>
                </li>

                <li class="layui-nav-item" lay-unselect style="margin-right:10px;">
                    <a href="javascript:;">
                        <cite>{$Think.session.admin_relname}</cite>
                    </a>
                    <dl class="layui-nav-child">
                        <dd id="editPassword"><a href="javascript:;">修改密码</a></dd>
                        <hr>
                        <dd id="logoutbutton" style="text-align: center;"><a href="javascript:;">退出</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-unselect>
                    <a href="javascript:;" layadmin-event="more"><i class="layui-icon layui-icon-more-vertical"></i></a>
                </li>
            </ul>
        </div>

        <!-- 侧边菜单 -->
        <div class="layui-side layui-side-menu">
            <div class="layui-side-scroll">
                <div class="layui-logo" lay-href="{:url('Console/console')}">
                    {if !empty($res)}
                    <span>{$res['team_name']}</span>
                    {else}
                      <span>旅游后台管理系统</span>
                    {/if}
                
                </div>

                <ul class="layui-nav layui-nav-tree" lay-shrink="all" id="LAY-system-side-menu" lay-filter="layadmin-system-side-menu">
                    {volist name="nav" id="item"}

                    <li class="layui-nav-item">
                        <a href="javascript:;" lay-tips="{$item.title.title}" lay-direction="2">
                            <i class="layui-icon {$item.title.icon}"></i>
                            <cite>{$item.title.title}</cite>
                        </a>
                        <dl class="layui-nav-child">
                            {volist name="item.nav" id="item2"}
                            <dd>
                                <a lay-href={$item2.name}>{$item2.title}</a>
                            </dd>
                            {/volist}
                        </dl>
                    </li>
                    {/volist}
                </ul>

            </div>
        </div>

        <!-- 页面标签 -->
        <div class="layadmin-pagetabs" id="LAY_app_tabs" style="padding-left: 0;">
            <div class="layui-icon layadmin-tabs-control layui-icon-down">
                <ul class="layui-nav layadmin-tabs-select" lay-filter="layadmin-pagetabs-nav">
                    <li class="layui-nav-item" lay-unselect>
                        <a href="javascript:;"></a>
                        <dl class="layui-nav-child layui-anim-fadein">
                            <dd layadmin-event="closeThisTabs"><a href="javascript:;">关闭当前标签页</a></dd>
                            <dd layadmin-event="closeOtherTabs"><a href="javascript:;">关闭其它标签页</a></dd>
                            <dd layadmin-event="closeAllTabs"><a href="javascript:;">关闭全部标签页</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>
            <div class="layui-tab" lay-unauto lay-allowClose="true" lay-filter="layadmin-layout-tabs">
                <ul class="layui-tab-title" id="LAY_app_tabsheader">
                    <li lay-id="{:url('Console/console')}" lay-attr="{:url('Console/console')}" class="layui-this"><i class="layui-icon layui-icon-home"></i></li>
                </ul>
            </div>
        </div>

        <!-- 主体内容 -->
        <div class="layui-body" id="LAY_app_body">
            <div class="layadmin-tabsbody-item layui-show">
                <iframe src="{:url('Console/console')}" frameborder="0" class="layadmin-iframe"></iframe>
            </div>
        </div>

        <!-- 辅助元素，一般用于移动设备下遮罩 -->
        <div class="layadmin-body-shade" layadmin-event="shade"></div>
    </div>
</div>

<!--修改密码-->
<div id="editPassModal"  style="display: none;padding:20px;">
    <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-form-item">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" lay-verify="editpassword" id="editpassword" placeholder="字母、数字、常用字符" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-block">
                <input type="password" lay-verify="editrepassword"  placeholder="再次输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
                <div class="layui-inline" style="left: 0;">
                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="editpasssubmit">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </div>
    </form>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form'], function(){
        var $ = layui.$
            ,layer = layui.layer
            ,form = layui.form
            ,element = layui.element;

        $('#logoutbutton').bind('click',function(){
            $.ajax({
                url: "{:url('Index/logout')}",
                type: 'post',
                dataType: 'json',
                data: {},
                success: function(msg){
                    if (msg.code == 0) {
                        layer.msg('退出成功',{icon:1,time:1000},function(){
                            var  url = "{:url('Login/login')}";
                            window.location.href = url;
                        });
                    }else{
                        layer.msg('退出失败',{icon:1,time:1000});
                    }
                }
            })
        });

        $('#editPassword').bind('click',function(){
            var editpassmodal = layer.open({
                title:'修改密码'
                ,type: 1
                ,shadeClose: true
                ,area:['500px']
                ,content: $('#editPassModal')
            });
        });

        form.verify({
            editpassword:[
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,editrepassword:function(value){
                if (value == '') {
                    return '请再次输入密码';
                }
                var password = $('#editpassword').val();
                if (value != password) {
                    return '两次输入的密码不同';
                }
            }
        });

        //修改密码提交
        form.on('submit(editpasssubmit)', function(data){
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            $.ajax({
                url: "{:url('Index/editPassword')}",
                type: 'post',
                dataType: 'json',
                data: {data:data.field},
                success: function(info){
                    if (info.code == "0") {
                        layer.msg('修改成功,请重新登录',{icon:1,time:1500},function(){
                            layer.closeAll();
                            var  url = "{:url('Login/login')}";
                            window.location.href = url;
                        });
                    }else{
                        layer.msg('修改失败',{icon:2,time:1500},function(){
                            layer.closeAll();
                        });
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });


    });
</script>
</body>
</html>


